Skip to content

fix(server): surface the declared 404 when deleting a missing message part - #1111

Merged
Astro-Han merged 1 commit into
devfrom
claude/i936-part-delete-404
Jun 3, 2026
Merged

fix(server): surface the declared 404 when deleting a missing message part#1111
Astro-Han merged 1 commit into
devfrom
claude/i936-part-delete-404

Conversation

@Astro-Han

Copy link
Copy Markdown
Owner

Summary

Part of the staged Effect error-contract migration (#936): turn a silent 200
into the route's already-declared 404. Follows #1109, which did the same for
session.deleteMessage.

DELETE /session/:sessionID/message/:messageID/part/:partID (part.delete)
declares errors(400, 404), but Session.removePart was a silent no-op: it
fired MessageV2.Event.PartRemoved and returned the id without checking
existence
, so deleting a part that does not exist returned 200. The declared
404 was a phantom.

Change

Add the existence check in the route handler (via Session.getPart, which
returns the part or undefined) and throw NotFoundError when the part is
missing — ErrorMiddleware maps it to 404 (and does not error-log it).

Why route-local, not in the service (unlike #1109): Session.removePart is
also called internally by the message processor (src/session/processor.ts:1295),
which must stay a tolerant no-op for an already-gone part. Putting the check in
removePart would change the processor's behavior. Keeping it in the route makes
the public contract real with a contained blast radius.

Behavior change & de-risk

The only change is that deleting a missing / already-removed part now returns the
already-declared 404 instead of a misleading 200. The desktop app does not
call this endpoint directly — it reacts to the message.part.removed SSE event —
so there is no frontend impact. The processor path is untouched (full session
suite stays green).

Verification

  • bun test test/server/session-messages.test.ts — 12 pass (the existing part update/delete test now also asserts the 404 on a re-delete)
  • bun test test/server/ — 332 pass
  • bun test test/session/ — 790 pass / 0 fail (confirms the processor's internal removePart use is unaffected)
  • bun run typecheck — clean

Deferred (known, tracked)

The checked-in packages/sdk/openapi.json snapshot / src/v2/gen types are
regenerated in a single batched resync PR at the end of the #936 series, not
per-slice. No functional impact (the app reacts to SSE, not this response).

Refs #936

… part

The DELETE /session/:sessionID/message/:messageID/part/:partID route
(part.delete) declares a 404, but Session.removePart was a silent no-op: it
fired MessageV2.Event.PartRemoved and returned the id without checking
existence, so deleting a part that does not exist returned 200. The declared
404 was a phantom.

Add the existence check in the ROUTE handler (via Session.getPart, which
returns the part or undefined) and throw NotFoundError when the part is missing
(ErrorMiddleware maps it to 404). Unlike deleteMessage, the check cannot live in
the service: Session.removePart is also called internally by the message
processor (src/session/processor.ts), which must stay a tolerant no-op for an
already-gone part. Keeping the check route-local makes the public contract real
without changing the processor's behavior.

No frontend impact: the desktop app does not call this endpoint directly (it
reacts to the message.part.removed SSE event). The only behavior change is that
deleting a missing/already-removed part now returns the already-declared 404.

Refs #936
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 16 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e76598a7-4665-465a-a0d9-d2991143d995

📥 Commits

Reviewing files that changed from the base of the PR and between 85bf4ae and 0694f60.

📒 Files selected for processing (2)
  • packages/opencode/src/server/instance/session.ts
  • packages/opencode/test/server/session-messages.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/i936-part-delete-404

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Astro-Han Astro-Han added bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority upstream Tracked upstream or vendor behavior labels Jun 3, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@Astro-Han
Astro-Han merged commit e506e38 into dev Jun 3, 2026
35 of 36 checks passed
@Astro-Han
Astro-Han deleted the claude/i936-part-delete-404 branch June 3, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority upstream Tracked upstream or vendor behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant